﻿using Godot.core;


namespace Godot.modules.gdscript
{
    public class GDNativeClass : Object
    {
        protected StringName _name;

        public StringName name
        {
            get
            {
                return _name;
            }
        }

        public GDNativeClass() { }

        public GDNativeClass(StringName p_name)
        {
            _name = p_name;
        }

        protected static void _bind_methods()
        {
            ObjectTypeDB.bind_method("new", (MbDel.MethodR0<Variant>)(new GDNativeClass().new_func));
        }

        protected bool _get(StringName p_name, ref Variant r_ret)
        {
            bool ok = false;
	        int v = ObjectTypeDB.get_integer_constant(name, p_name, ref ok);

	        if (ok) 
            {
		        r_ret = v;
		        return true;
	        } 
            else 
            {
		        return false;
	        }
        }

        public Object instance() 
        {
	        return ObjectTypeDB.instance(name);
        }

        public Variant new_func() 
        {
	        Object o = instance();
	        if (o == null) 
            {
		        //ERR_EXPLAIN("Class type: '"+String(name)+"' is not instantiable.");
		        return new Variant();
	        }
            return o;
        }
    }
}
